package edu.xidian.bdilab.jrbigdata.service.bank.enterprieseInfoCkeck.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import edu.xidian.bdilab.jrbigdata.controller.bank.BankCode;
import edu.xidian.bdilab.jrbigdata.controller.response.ResponseResult;
import edu.xidian.bdilab.jrbigdata.domain.EnterpriseInfo;
import edu.xidian.bdilab.jrbigdata.mapper.EnterpriseInfoMapper;
import edu.xidian.bdilab.jrbigdata.service.bank.enterprieseInfoCkeck.enterprieseInfoCkeckService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import static java.lang.Boolean.FALSE;
import static java.lang.Boolean.TRUE;

@Service
public class enterprieseInfoCkeckserviceimpl implements enterprieseInfoCkeckService {

    @Autowired
    EnterpriseInfoMapper enterpriseInfoMapper;
    @Override
    public ResponseResult enterprieseInfoCkeck(String social_code)
    {
        ResponseResult responseResult=new ResponseResult();
        QueryWrapper<EnterpriseInfo> enterpriseinfo_reqWrapper = new QueryWrapper<>();
        enterpriseinfo_reqWrapper.eq("social_code",social_code);
        EnterpriseInfo enterpriseInfo=enterpriseInfoMapper.selectOne(enterpriseinfo_reqWrapper);
        if(enterpriseInfo==null)
        {
            responseResult.setCode(BankCode.CHENCK_FAILED.getCode());
            responseResult.setMessage(BankCode.CHENCK_FAILED.getMessage());
            responseResult.setSuccess(FALSE);
        }


        else
        {
            responseResult.setData(enterpriseInfo);
            responseResult.setCode(BankCode.CHECK_SUCCESS.getCode());
            responseResult.setMessage(BankCode.CHECK_SUCCESS.getMessage());
            responseResult.setSuccess(TRUE);

        }

        return  responseResult;


    }
}
